package com.cmj.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cmj.dao.RoleMenuMapper;
import com.cmj.domain.entity.RoleMenu;
import com.cmj.service.RoleMenuService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service("roleMenuService")
public class RoleMenuServiceImpl extends ServiceImpl<RoleMenuMapper, RoleMenu> implements RoleMenuService {

    @Resource
    private RoleMenuMapper roleMenuMapper;

    @Override
    public int addRoleMenu(Long id,Long[] menuIds) {
        int insert = 0;
        for (Long menuId : menuIds) {
            RoleMenu roleMenu = new RoleMenu();
            roleMenu.setRoleId(id);
            roleMenu.setMenuId(menuId);
            insert = roleMenuMapper.insertRoleMenu(roleMenu);
        }
        return insert;
    }

    @Override
    public int delRoleMenu(Long id) {
        int i = roleMenuMapper.deleteById(id);
        return i;
    }
}